//
//  MYMainViewController.swift
//  sina
//
//  Created by liululu on 16/4/6.
//  Copyright © 2016年 liululu. All rights reserved.
//

import UIKit

class MYMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let mianTabbar = MYTabbar()
        
        setValue(mianTabbar, forKey: "tabBar")
        addChildViewControllers()
        
    }
    //添加子控制器
    
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(MessageTableController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(DiscoverTableController(), title: "发现", image: "tabbar_discover")
        addChildViewController(ProfileTableController(), title: "我", image: "tabbar_profile")
    }
    
    
    //设置子控制器
    func addChildViewController(vc: UIViewController,title:String,image:String) {
        vc.title = title
        vc.tabBarItem.image = UIImage(named: image)
        
        let nav = UINavigationController(rootViewController: vc)
        
        addChildViewController(nav)
    }

    
}
